First, I need to read in the data:
housedata <- read_csv("House_all_members.csv")
Now I need to create a year column:
housedata %>%
mutate(
year = 1789 + 2 * (congress - 1)
) -> housedata
Confirm that the years have the appropriate range:
range(housedata$year)
## [1] 1789 2017
Make a “polished” plot of the nominate_dim1 scores over time:
ggplot(housedata) +
aes(x = year,
y = nominate_dim1) +
geom_point(alpha = 0.2,
color = "gray") +
labs(x = NULL,
y = "DW-scores",
title = "Ideology of Congress over Time")
Do the same by party code and use geom_gitter:
ggplot(housedata) +
aes(x = year,
y = nominate_dim1,
color = factor(party_code)) +
geom_jitter(alpha = 0.1,
show.legend = F) +
labs(x = NULL,
y = "DW-scores",
title = "Ideology of Congress over Time")